<template>
  <div>
    <el-row>
      <el-col :span="12">
        <el-form-item :label="$t('基金认缴规模') + $t('金额单位')" prop="subscribeScale">
          <Money v-model="bfForm.subscribeScale" unit="w" :placeholder="$t('基金认缴规模')" />
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('基金实缴规模') + $t('金额单位')" prop="paidInScale">
          <Money v-model="bfForm.paidInScale" unit="w" :placeholder="$t('基金实缴规模')" />
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('基金投资类型')">
          <el-select v-model="bfForm.investType" filterable :placeholder="$t('请选择')">
            <el-option
              v-for="dict in fundInvestTypeOptions"
              :key="dict.dictValue"
              :label="$t(dict.dictLabel)"
              :value="dict.dictValue"
            />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('基金类型')">
          <el-select v-model="bfForm.fundType" filterable :placeholder="$t('请选择')">
            <el-option
              v-for="dict in fundTypeOptions"
              :key="dict.dictValue"
              :label="$t(dict.dictLabel)"
              :value="dict.dictValue"
            />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('基金阶段')" prop="fundStage">
          <el-select v-model="bfForm.fundStage" filterable :placeholder="$t('请选择')">
            <el-option
              v-for="dict in fundPhaseOptions"
              :key="dict.dictValue"
              :label="$t(dict.dictLabel)"
              :value="dict.dictValue"
            />
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('基金注册成立日')" prop="fundSetTime">
          <DatePicker v-model="bfForm.fundSetTime" :placeholder="$t('基金注册成立日')" />
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('管理公司')" prop="manageCompanyName">
          <el-autocomplete
            v-model="bfForm.manageCompanyName"
            class="inline-input"
            disabled
            :fetch-suggestions="companyQuerySearch"
            :placeholder="$t('管理公司')"
            :trigger-on-focus="false"
            :maxlength="100"
            @select="companyHandleSelect"
          />
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item :label="$t('管理公司认缴比例(%)')" prop="manageSubscribeRatio">
          <Ratio
            v-model="bfForm.manageSubscribeRatio"
            :min="0"
            :max="100"
            :placeholder="$t('管理公司认缴比例(%)')"
          />
        </el-form-item>
      </el-col>
    </el-row>
  </div>
</template>

<script>

import { gpListByName } from '@/api/fund/gp/gpBase'

export default {
  name: 'DealWfBfBaseForm',
  props: {
    // form
    bfForm: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      // 基金类型字典
      fundTypeOptions: [],
      // 基金投资类型
      fundInvestTypeOptions: [],
      // 基金阶段
      fundPhaseOptions: []
    }
  },
  mounted() {
    this.$bus.$emit('async_done')
  },
  created() {
    // 基金阶段字典
    this.getDicts('fund_phase').then(response => {
      this.fundPhaseOptions = response.data
    })
    // 基金性质字典
    this.getDicts('fund_nature').then(response => {
      this.fundNatureOptions = response.data
    })
    // 基金类型字典
    this.getDicts('fund_type').then(response => {
      this.fundTypeOptions = response.data
    })
    // 基金投资类型
    this.getDicts('fund_invest_type').then(response => {
      this.fundInvestTypeOptions = response.data
    })
  },
  methods: {
    // 标的公司查询
    companyQuerySearch(queryString, cb) {
      gpListByName(queryString).then(res => {
        if (res.code === 200) {
          cb(res.data)
        }
      })
    },
    // 标的公司选择后事件
    companyHandleSelect(item) {
      // GPid
      this.bfForm.manageCompany = item.id
      // GP名称
      this.bfForm.manageCompanyName = item.name
      // GP简称
      this.bfForm.manageCompanyAlias = item.shortName
    }
  }

}
</script>
